package com.situ.day2;

import org.junit.Test;

import java.util.Scanner;

public class IfDemo {
    @Test
    public void test2() {
        //你想表达什么意思,就起什么名字
        //int score = 9;
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入成绩：");
        int score = scanner.nextInt();
        if (score >= 90 && score <= 100) {
            System.out.println("优秀");
        } else if (score >= 80 && score < 90) {
            System.out.println("良好");
        } else if (score >= 70 && score < 80) {
            System.out.println("一般");
        } else if (score >= 60 && score < 70) {
            System.out.println("及格");
        } else {
            System.out.println("不及格");
        }
    }

    @Test
    public void test5() {
        //你想表达什么意思,就起什么名字
        //int score = 9;
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入成绩：");
        int score = scanner.nextInt();
        //卫语句1
        if(score < 0 || score > 100){
            System.out.println("这是非法输入");
            //方法后面的代码不再执行
            return;
        }
        if (score >= 90 && score <= 100) {
            System.out.println("优秀");
        } else if (score >= 80 && score < 90) {
            System.out.println("良好");
        } else if (score >= 70 && score < 80) {
            System.out.println("一般");
        } else if (score >= 60 && score < 70) {
            System.out.println("及格");
        } else {
            System.out.println("不及格");
        }
    }



    //三目运算符
    @Test
    public void test6(){
        //用英语按照一定规则把你想表达的意思表达出来
        int num1 = 22;
        int num2 = 15;
        int max = 0;
        if (num1 >= num2){
            max = num1;
        } else {
            max = num2;
        }
        System.out.println(max);

        int  max1 = num1 >=num2 ? num1 :num2;
        System.out.println(max1);
    }

    //+号运算符
    @Test
    public void test7(){
        int age = 24;
        //逗逗加加
        System.out.println("我的年龄是23岁");
        System.out.println("我的年龄是"+age+"岁");

        System.out.println(10 + 20 + "" + 30);
        System.out.println("" +10 +20 + 30);
    }
}
